<template>
  <div class="app-container">
    操作日志

    <!-- 表格 -->
    <el-table
      v-loading="listLoading"
      :data="list"
      stripe
      border
      style="width: 100%;margin-top: 10px;"
      @selection-change="handleSelectionChange"
    >

<!--      <el-table-column type="selection"/>-->

      <el-table-column
        label="序号"
        width="70"
        align="center"
      >
        <template slot-scope="scope">
          {{ (page - 1) * limit + scope.$index + 1 }}
        </template>
      </el-table-column>

      <el-table-column prop="title" label="模块标题"/>
      <el-table-column prop="operName" label="操作人"/>
      <el-table-column label="操作状态">
        <template slot-scope="scope">
          {{ scope.row.status == 1 ? '正常' : '异常' }}
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="操作时间" width="160"/>
      <el-table-column label="操作" width="200" align="center">
        <template slot-scope="scope">
          <el-button type="primary" @click="detail(scope.row.index)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页组件 -->
    <el-pagination
      :current-page="page"
      :total="total"
      :page-size="limit"
      style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper"
      @current-change="fetchData"
    />
    <el-dialog :visible.sync="dialogVisible" title="日志详情" width="600">
      <el-form  label-width="auto" >
        <el-form-item label="模块标题:" prop="title" >
          {{ list[index].title }}
        </el-form-item>
        <el-form-item label="部门名称:" prop="deptName" >
          {{ list[index].deptName }}
        </el-form-item>
        <el-form-item label="操作名称:" prop="operName" >
          {{ list[index].operName }}
        </el-form-item>
        <el-form-item label="jsonResult:" prop="jsonResult" >
          {{ list[index].jsonResult }}
        </el-form-item>
        <el-form-item label="operUrl:" prop="operUrl" >
          {{ list[index].operUrl }}
        </el-form-item>
        <el-form-item label="method:" prop="method" >
          {{ list[index].method }}
        </el-form-item>
        <el-form-item label="operParam:" prop="operParam" >
          {{ list[index].operParam }}
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
//引入定义接口的js文件
import api from '@/api/system/log'

export default {
  //定义初始值
  data() {
    return {
      listLoading: false,//是否显示加载
      list: [],//角色列表
      total: 0,//总记录数
      index: 0,//总记录数
      page: 1,//当前页
      limit: 10,//每页显示记录数
      searchObj: {},//条件查询封装对象

      dialogVisible: false,//弹出框
      sysRole: {}, //封装添加表单数据
      selectValue: [] //复选框选择内容封装数组
    }
  },
  //页面渲染之前执行
  created() {
    //调用列表方法
    this.fetchData()
  },
  methods: {//具体方法
    //条件分页查询列表
    //pageNum 查询页数
    fetchData(pageNum = 1) {
      //页数赋值
      this.page = pageNum
      //ajax
      api.getOperPageList(this.page, this.limit, this.searchObj)
        .then(response => {
          //this.listLoading = false
          //console.log(response)
          //每页数据列表
          this.list = response.data.records
          //总记录数
          this.total = response.data.total
        })
    },
    //修改-数据回显
    detail(index) {
      console.log(index)
      //弹出框
      // this.index = index
      this.dialogVisible = true
    }
  }
}
</script>
